/*
 * SpeedoDyno - Speedometer and dynamometer application for Android 
 * Copyright 2013 Guilhem VALENTIN
 * 
 * This file is part of SpeedoDyno
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with SpeedoDyno. If not, see <http://www.gnu.org/licenses/>.
 */
package com.gvalentin.speedodyno.listener;

import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.util.Log;

import com.gvalentin.speedodyno.SpeedoDynoActivity;

/**
 * Listener to manage location changes
 * @author guilhem
 */
public class SpeedoDynoLocationListener implements LocationListener {
	
	private static final String TAG = SpeedoDynoLocationListener.class.getSimpleName();
	
	private SpeedoDynoActivity activity;
	private LocationManager lManager;

	/**
	 * Constructor
	 */
	public SpeedoDynoLocationListener(SpeedoDynoActivity speedoDynoActivity, LocationManager lManager) {
		this.activity = speedoDynoActivity;
	}

	/**
	 * @see android.location.LocationListener#onLocationChanged(android.location.Location)
	 */
	@Override
	public void onLocationChanged(Location location) {
		Log.i(TAG, "onLocationChanged("+location+")");

		activity.updatePosition(location);
	}

	/**
	 * @see android.location.LocationListener#onProviderDisabled(java.lang.String)
	 */
	@Override
	public void onProviderDisabled(String provider) {
		Log.i(TAG, "onProviderDisabled("+provider+")");
		lManager.removeUpdates(this);
	}

	/**
	 * @see android.location.LocationListener#onProviderEnabled(java.lang.String)
	 */
	@Override
	public void onProviderEnabled(String provider) {
		Log.i(TAG, "onProviderEnabled("+provider+")");
	}

	/**
	 * @see android.location.LocationListener#onStatusChanged(java.lang.String, int, android.os.Bundle)
	 */
	@Override
	public void onStatusChanged(String provider, int status, Bundle extras) {
		Log.i(TAG, "onStatusChanged("+provider+","+status+","+extras+")");
	}
}
